<script type="text/javascript">

    function mycarousel_initCallback(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;

    jQuery(document).ready(function() {
        jQuery('#mycarousel').jcarousel({
            auto: 6,
            wrap: 'last',
            initCallback: mycarousel_initCallback
        });
    });

    function mycarousel_initCallback1(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;
    jQuery(document).ready(function() {

        jQuery('#mycarousel1').jcarousel({
            scroll: 1,
            rows: 2,
            animation: 'slow',
            auto: 3,
            wrap: 'last',
            initCallback: mycarousel_initCallback1
        });
    });

</script>


<?php
$id = $_GET['id'];
$shopcode = 'shop' . $id;
if (isset(Yii::app()->request->cookies[$shopcode]->value)) {
    $shoparry = Yii::app()->request->cookies[$shopcode]->value;
    $savedCardArray = json_decode($shoparry, true);
}
?>
<div class="header">
    <div class="headerBg">
        <div class="headerWidth">
            <div style="width: 100%">
                <div style="float: left; margin-right: 10px">
                    <a href="<?php echo Yii::app()->request->baseUrl; ?>/">

                        <img src="<?php echo Yii::app()->request->baseUrl . '/uploadshop/icon/' . $savedCardArray[3]; ?>" style="margin-top: 2px" height="58" />
                    </a>
                </div>
                <div style="float: left; width: 400px; ">
                    <div id='cssmenu'>
                        <ul>
                            <?php
                            $menu = ShopMenu::model()->findAll(' `flag`=1 and `parentID`=0 and `shopid`=' . $savedCardArray[0]);
                            if (!empty($menu)) {
                                foreach ($menu as $m) {
                                    ?>
                                    <li class='has-sub'><a href='<?php
                                        if (!empty($m->url)) {
                                            echo $m->url;
                                        } else {
                                            echo Yii::app()->request->baseUrl . '/shop/' . $savedCardArray[2] . '/' . $m->assia;
                                        }
                                        ?>'><span><?php echo $m->title; ?></span></a>
                                                           <?php
                                                           $menu1 = ShopMenu::model()->findAll(' `flag`=1 and `parentID`=' . $m->id . ' and `shopid`=' . $savedCardArray[0]);
                                                           if (!empty($menu1)) {
                                                               ?>
                                            <ul>
                                                <?php foreach ($menu1 as $m1) { ?>
                                                    <li class='has-sub'><a href='<?php
                                                        if (!empty($m1->url)) {
                                                            echo $m1->url;
                                                        } else {
                                                            echo Yii::app()->request->baseUrl . '/shop/' . $savedCardArray[2] . '/' . $m1->assia;
                                                        }
                                                        ?>'><span><?php echo $m1->title; ?></span></a>

                                                    </li>
                                                <?php } ?>
                                            </ul>
                                        <?php } ?>
                                    </li>
                                    <?php
                                }
                            }
                            ?>
                        </ul>
                    </div>
                </div>
                <div style="float:left;width: 300px">
                    <div class="searbox">
                        <form action="<?php echo Yii::app()->request->baseUrl; ?>/index.php/tim-dia-diem" method="post">

                            <div style="float:left;margin-left: 10px;">
                                <img src="<?php echo Yii::app()->request->baseUrl; ?>/icon/bg_location.png" style="margin-left: 10px;margin-top: 5px">
                            </div>
                            <div style="float: left; z-index: 9;">


                                <?php
                                
                                $models = ShopCity::model()->findAll(' `flag`=1 and `shopid`=' . $savedCardArray[14]);
                                print_r($models);
                                if (isset(Yii::app()->request->cookies['shopcityID']->value)) {
                                    $cityID = Yii::app()->request->cookies['shopcityID']->value;
                                } else {
                                    foreach ($models as $ct) {
                                        $cityID = $ct->id;
                                        break;
                                    }
                                }

                                $list = CHtml::listData($models, 'id', 'cityName');
                                echo CHtml::dropDownList('id', '', $list, array(
                                    'style' => 'width: 170px;background:#059373;border: 0px; color:white;font-size: 12px;font-weight: 600;',
                                    'options' => array($cityID => array('selected' => true)),
                
                                    'onchange' => 'document.location.href = "' . Yii::app()->request->baseUrl . '/shop/'.$savedCardArray[2].'/tim-dia-diem-shop/" + this.value'
                                ));
                                ?>
                            </div>
                            <div id='search' style="float: left; margin-left: -45px; z-index: 10">
                                <input type="text" name="key" placeholder="nhập từ khóa..." style="width: 218px; height: 29px"> 
                            </div>

                        </form>
                    </div>
                </div>
              

                <div style="clear: both"></div>

            </div>
        </div>
    </div>

</div>
